#include<stdio.h>
#include<sys/time.h>
enum Color
{
	GREEN=1,
	RED,
	BLUE,
	GREEN_RED=10,
	GREEN_BLUE
}ColorVal;

int CheckCPU()
{
	union w
	{
		int a;
		char b;
	}c;
	c.a = 1;
	printf(" sizeof(c) =%4ld \n",sizeof(c));
	return (c.b==1);
}
int main()
{
	printf("this a.c makefile testing Color size =%4ld\n",sizeof(ColorVal));
	//MAVERICK@desktop-42srdnb:/HOME/FTP/EMBEDED-LINUX-C/EMBEDED$ ./TEST
	//THIS A.C MAKEFILE TESTING cOLOR SIZE =   4
	printf("Check Cpu() is:\n");
	if(CheckCPU() == 1)
	{
		printf("little endin\n");
	}
	else
	{
		printf("big endin\n");
	}
	int a = 0;
	int i=1;
	a = (i++,++i,i+10);
	printf("a = %d\n",a);
	//^运算
	int m=10,n=20;
	//不用第三个数
	printf("before m=%d ,n = %d\n",m,n);
	m = n-m;
	n = n-m; //n = n - (n-m) = n - n + m = m
	m = m+n;//m = m + n = n -m + m = n
	printf("+after m=%d ,n = %d\n",m,n); 
	m=10;
	n=20;
	printf("^\n");
	printf("before ^ m = %d,n = %d\n",m,n);
	m = m^n;
	n = m^n;//m^n^n = m
	m = n^m;//m^m^n
	printf("after ^ m = %d,n = %d\n",m,n);
	printf("m = %d,m^m = %d\n",m,m^m);
	 printf("m = %d,m^m^m = %d\n",m,m^m^m);
	int arr[20000]={0};
	struct timeval start;
	struct timeval end;
	unsigned long timer;
	gettimeofday(&start,NULL);
	int tmp=0;
	for(int i=0;i<20000;i++)
	{
		tmp=arr[i];
		//printf("%d\t",tmp);
	}
	gettimeofday(&end,NULL);
	
	printf("for[] is %4ld\n",end.tv_usec-start.tv_usec);
	gettimeofday(&start,NULL);
	
	int *p;
	printf("address of arr [0]=%p arr[2000]=%p",&arr[0],&arr[2000]);
	for(p = arr;p<&arr[20000];++p)
	{
		tmp = *p;
	//	printf("%d\t",tmp);
	}

	gettimeofday(&end,NULL);
	printf("\nfor* is %4ld\n",end.tv_usec-start.tv_usec);
	
	//maverick@DESKTOP-42SRDNB:/home/ftp/embeded-linux-c/embeded$ ./test
//this a.c makefile testing Color size =   4
//Check Cpu() is:
// sizeof(c) =   4
//little endin
//a = 13
	return 0;
}
